package com.xjc.system.config;

import com.xjc.system.interceptor.TokenInterceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 徐锦程
 * 时间:2024-10-01 16:19
 * 描述:注册拦截器
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    private static final Logger logger = LoggerFactory.getLogger(WebConfig.class);
    /**
     * 添加拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        // token验证
        registry.addInterceptor(new TokenInterceptor())
                .addPathPatterns("/**") // 拦截所有路径
                .excludePathPatterns(
                    "/sys_admin/user/login",
                    "/sch_admin/user/register",
                    "/sch_admin/user/login",
                    "/college_admin/user/login",
                    "/class_admin/user/login",
                    "/student/user/login",
                    "/door/user/login",
                    "/build_admin/user/login",
                    "/file/**",
                    "/xlsx/**",
                    "/",
                    "/sch_admin/set/back/**"
                ); // 排除不需要验证的路径

    }
}
